package com.dragon.pear.pages.tabs.main.mine;

import com.chris.libs.base.x.mvpp.mvpp.AbsStandardFragmentViewProxy;
import com.chris.libs.devtools.x.v1.utils.widget.TextViewUtil;
import com.dragon.pear.common.utils.FunItemUtil;
import com.dragon.pear.pages.common.login.LoginActivity;

import javax.inject.Inject;


/**
 * @author Chris chan
 * Create on： 2025/2/1 19:40
 * Use for: UI界面元素处理代理类
 * Explain:
 */
public class MineViewProxy extends AbsStandardFragmentViewProxy implements MineContract.UIView {
    private MineViewModel viewModel;
    @Inject
    MineViewHolder vh;
    @Inject
    MinePresenter presenter;
    //@Inject
    MineViewModel mineViewModel;

    @Inject
    public MineViewProxy() {
    }

    @Override
    protected void init() {
        this.viewModel = getViewModel(MineViewModel.class);
        this.mineViewModel = getGlobalViewModel(MineViewModel.class);
        this.vh.bind(this.contentView);
        this.presenter.bindView(this);
        this.presenter.setViewModel(this.viewModel);
    }

    @Override
    protected void initView() {
        FunItemUtil.addButton(this.context, this.vh.llContainer, "Build工具测试", LoginActivity.class);
    }

    @Override
    protected void setupEvent() {
        // 测试全局数据
        update(this.mineViewModel.getUserInfo(), result -> {
            vh.llContainer.addView(TextViewUtil.of(context, result.getUsername()));
        });
    }

    @Override
    protected void onReady() {
        //this.presenter.requestAndUpdate();
    }

//    @OnClick({R.id.tv_info})
//    public void onClick(View view) {
//        showMessage("我的文本框被点击了");
//    }
}
